import app from "../../../app";
import god from "../../../god";
import { Tpl_attribute_pet, template } from "../../../shared/master/MsgAction";
import word from "../../word/word";
import { SKILL } from "../skill/SK_active";
import { _Cls_Att } from "./att/_Att";
import { _Cls_Points } from "./att/_Points";
import { CreateBody_base, baseBody } from "./baseBody";
export class enemy extends baseBody {
    icon: string = '👻';
    private _word!:word;
    constructor() {
        super()
        this.setBodyType('enemy')
    }
    set_Cfg(data: CreateBody_base) {
        // TODO删除出现bug
        SKILL
        super.set_Cfg(data)
        this.P.Hp_Max += data.leve * 10
        // this.name = data.name;
        // this.P = new _Cls_Points(data.Points);
        // this.leve.num = data.leve;
        // for (let index = 0; index < data.sk_actives.length; index++) {
            // const element = data.sk_actives[index];
        // }
    }
    getMsgAttTpl() {
        this.update_attributes();
        let p = new _Cls_Points();
        p.add(this.P);
        p.add(this.Job);


        let att = new _Cls_Att();
        att.reset(this._attributes);
        let tpl: Tpl_attribute_pet = {
            render_type:'pet_concise',
            name: this.name,
            hp_now: this.Hp_now,
            score:this.getScore(),
            mp_now: this.Mp_now,
            leve: this.leve,
            Points: p,
            attributes: att,
            body_type: "pet",
            style_id: this.style_id
        }
        return {template:template.attribute_pet,data:tpl};
    }
    destroy(): void {
      super.destroy();
    }
    /**
     * 特殊单位专用
     * @param w 
     */
    setWord(w:word){
        this._word = w;
    }
     /**
   * 
   * @param cfg 
   * 记录创建配置
   */
     setCreateCfg(cfg: any) {
        this.createCfg = cfg;
    }
    /**
     * 随机掉落道具
     */
    RandomFallDown_v2(){
        let word = this._word || this.getPosition()?.getWord();
        if(!word){
            debugger;
        }
        let score = app.random(word.cfg.fallScoreMin, word.cfg.fallScoreMax)
        return {score:score,name:`${word.name}-${this.name}掉落`}
    }

}